package com.lqh.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lqh.bean.Bill;
import com.lqh.dao.BillMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: liuqihong
 * @Description:
 * @Date Created in  2021-02-03 16:19
 * @Modified By:
 */
@Service
public class BillService {

    @Autowired
    private BillMapper mapper;

    public List<Bill> list(Bill bill){
        return mapper.select(bill);
    }

    public int add(Bill bill){
        return mapper.insert(bill);
    }

    public int update(Bill bill){
        return mapper.updateByPrimaryKey(bill);
    }

    public Bill get(long id){
        return mapper.selectByPrimaryKey(id);
    }

    public int delete(long id){
        return mapper.deleteByPrimaryKey(id);
    }

    public PageInfo<Bill> listPage(Bill b, int pageNum, int pageSize) {
        return PageHelper.startPage(pageNum,pageSize).doSelectPageInfo(() -> {
           mapper.select(b);
        });
    }

}
